package com.example.demo.xml;


import com.example.demo.model.User;
import com.example.demo.service.TestUserService;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author yujie
 * @create 2018-04-26 下午5:19
 **/
public class Test {

    public static void main(String[] args) throws Exception {
        Resource resource = new ClassPathResource("applicationContext.xml");
        /**
         * 扩展spring schema
         *
         * 1、META-INF/spring.handlers  schema与handler对应关系
         * 2、META-INF/spring.schemas    schema与xsd对应关系
         * 3、继承AbstractBeanDefinitionParser 实现解析
         * 4、继承NamespaceHandlerSupport类实现 init getBeanClass doParse方法
         * init 注册名称与解析类对应关系
         * getBeanClass 返回bean类型
         * doParse 具体处理
         */

//        XmlBeanFactory xmlBeanFactory = new XmlBeanFactory(resource);
//        User u = xmlBeanFactory.getBean(User.class);


        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
//        User u = context.getBean(User.class);
//        TestUserService testUserService = context.getBean(TestUserService.class);
//        testUserService.st();
        TestBeanPostProcessor testBeanPostProcessor = context.getBean(TestBeanPostProcessor.class);
        System.out.println(testBeanPostProcessor);
    }
}
